<template>
  <div class="main" :class="isLook ? 'main-none' : ''">
    <myForm
      ref="myForm"
      :dataForm="dataForm"
      :isLook="isLook"
      :showFooter="true"
      :confimText="isLook ? '编辑信息' : '提交审核'"
      :formItem="formItem"
      @cancel="cancel"
      @handleSubmit="handleSubmit"
      @handleEdit="handleEdit"
    />
  </div>
</template>

<script>
import myForm from './components/myForm.vue';
import { addDamInfoRecord } from '@/api/record.js';

export default {
  components: { myForm },
  props: {
    dataForm: {
      type: Object,
      default: () => {
        return {};
      }
    },
    isLook: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formItem: [
        {
          key: 'materialSource',
          propsType: 'editor'
        }
      ]
    };
  },
  methods: {
    handleSubmit(values) {
      values.damId = this.dataForm.id;
      values.panelType = 100;
      addDamInfoRecord(values).then(res => {
        if (res.code == 0) {
          this.$emit('cancel', true);
        }
      });
    },
    handleEdit() {
      this.$emit(
        'handleEdit',
        {
          key: 'materialSource',
          label: '料源'
        },
        false
      );
    },
    cancel() {
      this.$emit('cancel');
    },
    resetFields() {
      this.$refs.myForm.resetFields();
    }
  }
};
</script>

<style scoped lang="scss">
.main-none {
  .main ::v-deep .w-e-toolbar {
    display: none;
  }
}
</style>
